<?php
echo "<!doctype html>
<head>
<title>adhoc</title>
<style>
.bad { color: red; }
.wc { color: green; }
.suggested { color: brown; }
</style>
</head>
<body>\n";
// $lang = "de_DE.utf8";
// putenv("LANG=$lang");
// setlocale(LC_MESSAGES, $lang);
// $domain = "messages";
// bindtextdomain($domain, "/home/eagle/public_html/locale");
// textdomain($domain);
// echo gettext("Hello world proof page project.");
// echo gettext("characters");

$relPath='./pinc/';
require_once $relPath."dpinit.php";
require_once $relPath."dp_main.inc";
init_timer();

// $projectid = "111129002";  // corinne
// $langcode = "it";
// $pagename = "427";

// $projectid = "110815001"; // Test project #2
// $pagename = "004";
// $langcode = "en";

$projectid = "120502001";
$pagename = "041";
$langcode = "it";

$project = new DpProject($projectid);
$page = new DpPage($projectid, $pagename);

// dump($page->SuggestedWordsArray($langcode));
$w_array = array("poppattola");
$swa = $project->SuggestedWordsArray($langcode);

dump($swa);
foreach($w_array as $w) {
    dump($w);
    $swa[] = $w;
}
$swa = array_unique($swa);
dump($swa);
$project->WriteSuggestedWordsArray($langcode, $swa);
dump($swa);
$project->RefreshSuggestedWordsArray($langcode);
dump($project->SuggestedWordsArray($langcode));
    
die();
$page->SuggestWordsArray($langcode, array("poppattola"));
dump($page->SuggestedWordsArray($langcode));
die();

// $project->SubmitGoodWordsArray($langcode,
    // array("Barrington", "Bogg", "China-grass", "Crabtree",
        // "china-grass", "empty", "one", "weed"));
// dump($project->GoodWordsArray($langcode));
// $project->DeleteGoodWord($langcode, "Bogg");
// dump($project->GoodWordsArray($langcode));
dump($project->SuggestedWordsArray($langcode));
$project->DeleteSuggestedWord($langcode, "Six-penny");
dump($project->SuggestedWordsArray($langcode));
die();
dump($project->BadWordsArray($langcode));
dump($project->SuggestedWordsArray($langcode));

die();


// $projectid = "111202001";
// $langcode = "it";
// $pagename = "091";

// $projectid = "110930002";  // corinne
// $word      = "rome";
// $langcode = "fr";
// $projectid = "110815001";
// $langcode = "en";


// $projectid = ArgProjectId("120101001");
// $pagename = ArgPageName("206");
// $langcode = ArgLangCode("de");
// $projectid = ArgProjectId("111001002");     // Aus Italien
// $pagename = ArgPageName("172");
// $langcode = ArgLangCode("de");

// $projectid = "110526001";  // britannica
// $langcode = "de";
// $projectid = "111208001";
// $langcode = "en";
// $pagename = "22j880a";
// say_timer();
// say("before new project");

$project = new DpProject($projectid);
$page = new DpPage($projectid, $pagename);
say_timer();

die();

$ew = $page->EnchantedWords($langcode);
dump($ew->Command());
dump("RawOutput()");
dump($ew->RawOutput());
dump( "WordsArray()");
dump( $ew->WordsArray());
// $text = $page->ActiveText();
dump( "GoodWordsArray()");
dump($project->GoodWordsArray($langcode));
dump( "SuggestedWordsArray()");
dump($page->SuggestedWordsArray($langcode));
dump( "GoodWordsArray() - SuggestedWordsArray()");
dump($a = array_diff($project->SuggestedWordsArray($langcode),
                $project->GoodWordsArray($langcode)));
                
$wct = $page->WordCheckText($langcode, $text);
dump(("page->WordCheckText"));
dump($wct);
$swla = $page->SpellWordLineArray($langcode);
dump(h("SpellWordLineArray"));
dump($swla);
die();
// dump($wa);
$project->RefreshSuggestedWordsArray($langcode);
dump($project->SuggestedWordsArray($langcode));
die();
$sugg = $project->SuggestedWordsArray($langcode);
sort($sugg);
dump($sugg);
die();
$good = $project->GoodWordsArray($langcode);
sort($good);
dump($good);
$bad = $project->BadWordsArray($langcode);
sort($bad);
dump($bad);
$a = array_diff($sugg, $good, $bad);
dump($a);
$project->ReplaceSuggestedWordsArray($langcode, $a);
dump($project->SuggestedWordsArray($langcode));
die();
        // $project->ReplaceSuggestedWordsArray(
dump(
            array_diff($project->SuggestedWordsArray($langcode),
                        $project->GoodWordsArray($langcode),
                        $project->BadWordsArray($langcode))
);
// $project->ReplaceSuggestedWordsArray(
die();

$page = new DpPage($projectid, $pagecode);
die();


say_timer();
// $text = $page->SpellWordLinesArray($langcode);
// dump($text);
// $wt = $project->GoodWordsByCountAlpha($langcode);
// $wt = $project->GoodWordCounts($langcode);
// $wt = $project->GoodWordsArray($langcode);
// say("FlagWordsByCountAlpha");
$ench = $project->EnchantedWords($langcode);
$fwca = $ench->WordsArray();
say_timer();
dump($fwca);
die();
// say("dump WordContext for $word");
// dump($project->WordContext($word));
// die();
// $tl = text_lines($t);
// $a = $project->TextWordCounts();
// foreach($project->ActivePageRows() as $row) {
    // $pgtext = $row['active_text'];
    // $_rows = array_merge($_rows, text_lines($pgtext));
    // $_pgs[] = array('pagename' => $row['pagename'],
                // 'maxrow' => count($_rows));
// }
// say_timer();
// die();
// dump(count($_rows));
// dump($_pgs);


// $swc = $project->WordContext($langcode, "de");
// dump($swc);
// die();

say("spellwordsarray");
$sw = $project->SpellWordsArray($langcode);
// edump($fw);
// die();
f($sw);

say("goodwordsarray");
$gw = $project->GoodWordsArray($langcode);
f($gw);

// say("diff");
// $w = array_diff($sw, $gw);
// f($w);

say("badwordsarray");
$bw = $project->BadWordsArray($langcode);
f($bw);


say("SuggestedWordCountArray");
$sug = $project->SuggestedWordCountArray($langcode);
f($sug);

say("FlagWordsByCountAlpha");
$fwca = $project->FlagWordsByCountAlpha($langcode);
f($fwca);

say("GoodWordsByCountAlpha");
$gwca = $project->GoodWordsByCountAlpha($langcode);
f($gwca);
say("BadWordsByCountAlpha");
$bwca = $project->BadWordsByCountAlpha($langcode);
f($bwca);
say("SuggestedWordsByCountAlpha");
$swca = $project->SuggestedWordsByCountAlpha($langcode);
f($swca);

die();

?>
